// components/tab/tab.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    tab: {
      type: Object,
      value: {
        list: {
          type: Array,
          value: [{
            id: {
              type: Number,
              value: 0
            },
            title: {
              type: String,
              value: ""
            }

          }]
        },
        selectedId: {
          type: Number,
          value: 0
        },
        scroll: {
          type: Boolean,
          value: false
        }
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleTabChange: function (e) {
      var dataset = e.currentTarget.dataset;
      var selectedId = dataset.itemId;
      var selectTitle = dataset.title;
      var index = dataset.index;
      var data = { selectedId, selectTitle, index };

      this.setData({
        'tab.selectedId': selectedId
      });
      var myEventOption = {} // 触发事件的选项
      this.triggerEvent('tabTap', data)
    }
  }
})